package com.example.democlient;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TabHost;

public class TaskActivity extends TabActivity {
    private MyApplication app;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_task);  
        app = (MyApplication)this.getApplication();
        app.addActivity(this);
        
    	Intent _intent = getIntent();
    	String fromValue = null;
    	if(_intent!=null){
    		fromValue = _intent.getStringExtra("from");
    	}
		
        TabHost tabHost =  getTabHost();    
        
        
        Intent intent = new Intent();
        intent.setClass(this, TaskListActivity.class);
        
        Intent intent1 = new Intent();
        intent1.setClass(this, RoadDesignActivity.class);
        
        
        tabHost.addTab(tabHost.newTabSpec("tab1")
                .setIndicator("收派任务",getResources().getDrawable(R.drawable.task_list))
                .setContent(intent));
        tabHost.addTab(tabHost.newTabSpec("tab3")
                .setIndicator("路线规划",getResources().getDrawable(R.drawable.road_design))
                .setContent(intent1));
        
        if(fromValue!=null){
        	tabHost.setCurrentTab(1);
        }
    }
    
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    public boolean onOptionsItemSelected(MenuItem item){
    	super.onOptionsItemSelected(item);
    	if(item.getItemId()==R.id.menu_settings){
    		app.exit();
    	}
		return true;
    }
}
